package org.example.xsda.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web MVC 配置
 * 配置本地文件静态资源访问
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    
    @Value("${file.storage.local-path}")
    private String localStoragePath;
    
    @Value("${file.storage.url-prefix}")
    private String urlPrefix;
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置本地文件访问路径
        // 访问URL: /files/** -> 映射到本地路径: E:/file/XSDA/**
        registry.addResourceHandler(urlPrefix + "/**")
                .addResourceLocations("file:" + localStoragePath + "/");
    }
}

